package file;

import java.io.*;

/**
 * @author wang hao
 * @date 2023-04-02 09:51
 */
public class Demo08 {
    public static void main(String[] args) throws Exception {
        // 每次读取一个字符
        FileReader fr = new FileReader("src/main/java/file/1.txt");
        int len;
        while ( (len = fr.read()) != -1){
            System.out.printf(String.valueOf((char) len));
        }

        System.out.println();
        fr = new FileReader("src/main/java/file/1.txt");
        BufferedReader br = new BufferedReader(fr);
        len = 0;
        char[] chars = new char[1024];
//        while ((len = br.read(chars)) != -1){
//            System.out.printf(new String(chars, 0, len));
//        }
        String s = br.readLine();
        System.out.println(s);
        br.close();
        fr.close();
    }
}
